<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目名称">
              <select-project-input
                placeholder="请选择项目"
                v-model="queryParam.projectId"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="作废任务">
              <select-project-task-input
                v-model="queryParam.taskId"
                :isRefresh="true"
                placeholder="请选择任务分类"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="任务id">
              <a-input placeholder="请输入任务id" v-model="queryParam.taskId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="任务id">
              <a-input placeholder="请输入任务id" v-model="queryParam.taskId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="异常标识">
              <a-input placeholder="请输入异常标识" v-model="queryParam.errorFlag"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="流程实例">
              <a-input placeholder="请输入流程实例id" v-model="queryParam.processInstId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="触发流程">
              <a-input placeholder="请输入触发流程" v-model="queryParam.tiggerModule"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="触发流程id">
              <a-input placeholder="请输入触发流程id" v-model="queryParam.tiggerId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="作废流程">
              <a-input placeholder="请输入作废流程" v-model="queryParam.flowName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="作废流程主键">
              <a-input placeholder="请输入作废流程主键" v-model="queryParam.formDataId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset()" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus" :disabled="isDisabledAuth('erpProcessLog:add')">新增
      </a-button>
      <!--<a-button type="primary" icon="download" @click="handleExportXls('erp流程删除日志')" :disabled="isDisabledAuth('erpProcessLog:export')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpProcessLog:import')">导入</a-button>
      </a-upload>
      -->
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item,index) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12" :key="index">
                    <a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox>
                  </a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;">
          <a-icon type="setting" :style="iconStyle"/>
        </a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <template slot="status" slot-scope="status">
          <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

      </a-table>
    </div>

    <erp-process-log-modal ref="modalForm" @ok="modalFormOk"></erp-process-log-modal>
  </a-card>
</template>

<script>
import SelectProjectTaskInput from '@/views/scy/components/SelectProjectTaskInput'
import SelectProjectInput from '@/views/scy/components/SelectProjectInput';
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpProcessLogModal from './modules/ErpProcessLogModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'

export default {
  name: 'ErpProcessLogList',
  mixins: [JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
  components: {
    ErpProcessLogModal,
    SelectProjectTaskInput,
    SelectProjectInput
  },
  data() {
    return {
      description: 'erp流程删除日志管理页面',
      // 表头
      columns: [],
      // 列设置
      settingColumns: [],
      showFlowSubmitButton: {
        type: Boolean,
        default: false,
        required: false
      },
      // 列定义
      defColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '创建人',
          align: 'center',
          dataIndex: 'createBy_dictText'
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '触发流程',
          align: 'center',
          dataIndex: 'flowModule_dictText'
        },
        {
          title: '触发流程id',
          align: 'center',
          dataIndex: 'tiggerId'
        },
        {
          title: '作废流程',
          align: 'center',
          dataIndex: 'flowName'
        },
        {
          title: '相关任务',
          align: 'center',
          dataIndex: 'taskId_dictText'
        },
        {
          title: '作废流程id',
          align: 'center',
          dataIndex: 'formDataId'
        },
        {
          title: '项目信息',
          align: 'center',
          dataIndex: 'projectId_dictText'
        },
        {
          title: '流程实例Id',
          align: 'center',
          dataIndex: 'processInstId'
        },
        {
          title: '日志信息',
          align: 'center',
          dataIndex: 'msg'
        },
        {
          title: '异常标识',
          align: 'center',
          dataIndex: 'errorFlag'
        },
        {
          title: '操作类型',
          align: 'center',
          dataIndex: 'taskOperationType_dictText'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 160,
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }
      ],
      url: {
        list: '/api/erp/log/erpProcessLog/list',
        delete: '/api/erp/log/erpProcessLog/delete',
        deleteBatch: '/api/erp/log/erpProcessLog/deleteBatch',
        exportXlsUrl: '/api/erp/log/erpProcessLog/exportXls',
        importExcelUrl: '/api/erp/log/erpProcessLog/importExcel'
      },
      dictOptions: {},
      superFieldList: []
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
    formDisabled() {
      return this.disabled
    }
  },
  methods: {
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'handlerId', text: '经办人编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'handlerDeptId', text: '经办人部门ID', dictCode: '' })
      fieldList.push({ type: 'string', value: 'handlerDeptCode', text: '经办人部门编码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'delFlag', text: '是否已删除', dictCode: '' })
      fieldList.push({ type: 'string', value: 'flowModule', text: '触发流程', dictCode: '' })
      fieldList.push({ type: 'string', value: 'flowName', text: '作废流程', dictCode: '' })
      fieldList.push({ type: 'Text', value: 'taskId', text: '任务id', dictCode: '' })
      fieldList.push({ type: 'string', value: 'projectId', text: '项目id', dictCode: '' })
      fieldList.push({ type: 'string', value: 'processInstId', text: '流程实例Id', dictCode: '' })
      fieldList.push({ type: 'Text', value: 'msg', text: '日志', dictCode: '' })
      fieldList.push({ type: 'string', value: 'errorFlag', text: '异常标识', dictCode: '' })
      fieldList.push({ type: 'string', value: 'formDataId', text: '作废流程主键', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
